--local function on_cursor_move()
--  local current_line = vim.api.nvim_get_current_line()
--  local math_env = vim.api.nvim_eval("vimtex#syntax#in_mathzone()")
--  print("当前行：" .. current_line .. math_env)
-- end
return {
  "lervag/vimtex",
  lazy = false,
  config = function()
    -- 使用skim双向定位，
    -- skim同步选项：自定义，命令是 nvim
    -- 参数为 --headless -c "VimtexInverseSearch %line '%file'"
    vim.g.vimtex_view_method = "zathura"
    -- vim.g.vimtex_view_method = "sioyek"
    --vim.g.vimtex_view_general_options = "-r @line @pdf @tex"
    vim.g.vimtex_view_skim_sync = 1
    vim.g.vimtex_view_skim_activate = 1
    -- vim.g.vimtex_view_automatic = 0
    -- vim.g.vimtex_quickfix_mode = 1
    -- 2:编译出错时，quickfix 窗口在非焦点状态下打开，不会自动切换到该窗口
    vim.g.vimtex_quickfix_open_on_warning = 0
    -- vim.g.vimtex_compiler_methon = "latexmk"
    -- vim.g.vimtex_compiler_latexmk_engines = {
    --     latex = "pdflatex",
    --     pdflatex = "pdflatex",
    --     xelatex = "xelatex",
    --     lualatex = "lualatex",
    -- }
    -- vim.g.vimtex_compiler_engine='xelatex'
    vim.g.vimtex_compiler_latexmk = {
      aux_dir = "./.latexmk/aux",
      out_dir = "./.latexmk/out",
      -- executable = "latexmk",
      options = {
        "-xelatex",
        "-pdf",
        "-shell-escape",
        "-verbose",
        "-file-line-error",
        "-synctex=1",
        "-interaction=nonstopmode",
      },
    }
    --   vim.api.nvim_create_autocmd("CursorMovedI", {
    --     --pattern = { "bib", "tex" },
    --     pattern = "*",
    --     callback = on_cursor_move,
    --   })

    vim.g.vimtex_mappings_disable = { ["n"] = { "K" } } -- disable `K` as it conflicts with LSP hover
    vim.g.vimtex_syntax_enabled = 0
    vim.g.vimtex_syntax_conceal_disable = 0
    vim.wo.conceallevel = 0
  end,
  --ft = { "tex", "latex" },
}
